<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-form label-width="auto" style="max-width: 700px">
        <el-form-item>
          <el-input size="large" style="width: 500px" placeholder="请输入内容" />
          <el-button :icon="Search" style="width: 50px;" size="large" />
          <el-button type="primary" size="large" class="box_button">添加用户</el-button>
        </el-form-item>
        <el-form-item>
        </el-form-item>
      </el-form>
      <el-table :data="tableData" style="width: 100%" border stripe>
        <el-table-column type="index" label="序号" width="60" />
        <el-table-column prop="username" label="姓名" width="180" />
        <el-table-column prop="email" label="邮箱" />
        <el-table-column prop="mobile" label="电话" />
        <el-table-column prop="role_name" label="角色" />
        <el-table-column label="状态" />
        <el-table-column label="操作" />
      </el-table>
      <!-- size-change	page-size 改变时触发   current-change	current-page 改变时触发  v-model:page-size	每页显示条目个数  v-model:current-page	当前页数-->
      <el-pagination v-model:current-page="currentpage" v-model:page-size="pagesize" :page-sizes="[1, 2, 5, 10]"
        layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="pagesize"
        @current-change="currentpage" />
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { Search } from '@element-plus/icons-vue'
import request from '@/util/request'
const tableData = ref([])
const currentpage = 1
const pagenum = 1
const pagesize = 2
const total = ref(0)
const getMenu = async () => {
  const { data } = await request({
    url: `/users?pagenum=${pagenum}&pagesize=${pagesize}`,
    method: 'GET'
  })
  tableData.value = data.users
  total.value = data.total
}
getMenu()
</script>

<style scoped>
.el-card {
  margin-top: 20px;
}

.box_button {
  margin-left: 30px
}

.el-pagination {
  margin-top: 10px
}
</style>